/* Copyright 2009 Requirements Management System 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.mags.remas.model.entity.provider;

import org.mags.dao.provider.AbstractProviderFactory; 

/**
 * .
 * @author Mario Gaitan
 *
 */
public class EntityProviderFactory extends AbstractProviderFactory {
	private EntityProvider entityProvider;
	private EntityRelationshipProvider entityRelationshipProvider;
	private EntityStructureProvider entityStructureProvider;
	private EntityTypeProvider entityTypeProvider;
	private EntityStatusProvider entityStatusProvider;
	private EntityCategoryProvider entityCategoryProvider;
	private ViewTypeProvider viewTypeProvider;
	private EntityFileProvider entityFileProvider;
	private EntityCommentProvider entityCommentProvider;
	private CommentTypeProvider commentTypeProvider;
	private ReferenceStatusProvider referenceStatusProvider;
	private EntityReferenceProvider entityReferenceProvider;
	private KeyTypeProvider keyTypeProvider;
	private EnumNameProvider enumNameProvider;
	private EnumValueProvider enumValueProvider;
	private KeyDefinitionProvider keyDefinitionProvider;
	private KeyValueProvider keyValueProvider;
	private ListValueProvider listValueProvider;
	private ListNameProvider listNameProvider;	
	private SystemPropertyProvider systemPropertyProvider;
	
	public static final String ID = "entity";
	
	
	public EntityProviderFactory() {
		super(ID);
	}	
	public void refreshAll() {
		getKeyTypeProvider().refreshAll();
		getEnumNameProvider().refreshAll();
		getKeyDefinitionProvider().refreshAll();
		getListNameProvider().refreshAll();
		
		getCommentTypeProvider().refreshAll();
		getEntityCategoryProvider().refreshAll();
		getEntityStatusProvider().refreshAll();
		getViewTypeProvider().refreshAll();
		getEntityTypeProvider().refreshAll();
		getEntityStructureProvider().refreshAll();
		getReferenceStatusProvider().refreshAll();
		getSystemPropertyProvider().refreshAll();
	}
	public EntityReferenceProvider getEntityReferenceProvider() {
		if(entityReferenceProvider==null)
			entityReferenceProvider = new EntityReferenceProvider(getReferenceStatusProvider());
		entityReferenceProvider.setDao(dao);
		return entityReferenceProvider;
	}	
	public CommentTypeProvider getCommentTypeProvider() {
		if(commentTypeProvider==null)
			commentTypeProvider = new CommentTypeProvider();
		commentTypeProvider.setDao(dao);
		return commentTypeProvider;
	}
	public EntityCommentProvider getEntityCommentProvider() {
		if(entityCommentProvider==null)
			entityCommentProvider = new EntityCommentProvider(this.getCommentTypeProvider());
		entityCommentProvider.setDao(dao);
		return entityCommentProvider;
	}
	public EntityFileProvider getEntityFileProvider() {
		if(entityFileProvider==null)
			entityFileProvider = new EntityFileProvider();
		entityFileProvider.setDao(dao);
		return entityFileProvider;
	}
	public ViewTypeProvider getViewTypeProvider() {
		if(viewTypeProvider==null)
			viewTypeProvider = new ViewTypeProvider();
		viewTypeProvider.setDao(dao);
		return viewTypeProvider;
	}
	public EntityCategoryProvider getEntityCategoryProvider() {
		if(entityCategoryProvider==null)
			entityCategoryProvider=new EntityCategoryProvider();
		entityCategoryProvider.setDao(dao);
		return entityCategoryProvider;
	}
	public ReferenceStatusProvider getReferenceStatusProvider() {
		if(referenceStatusProvider==null)
			referenceStatusProvider = new ReferenceStatusProvider();
		referenceStatusProvider.setDao(dao);
		return referenceStatusProvider;
	}	
	public EntityStatusProvider getEntityStatusProvider() {
		if(entityStatusProvider==null)
			entityStatusProvider = new EntityStatusProvider();
		entityStatusProvider.setDao(dao);
		return entityStatusProvider;
	}
	public EntityProvider getEntityProvider() {
		if(entityProvider==null)
			entityProvider = new EntityProvider(this.getEntityTypeProvider(), this.getEntityStatusProvider(), this.getEntityCategoryProvider());
		entityProvider.setDao(dao);
		return entityProvider;
	}
	public EntityRelationshipProvider getEntityRelationshipProvider() {
		if(entityRelationshipProvider==null)
			entityRelationshipProvider = new EntityRelationshipProvider(this.getEntityTypeProvider(), getKeyTypeProvider());
		entityRelationshipProvider.setDao(dao);
		return entityRelationshipProvider;		
	}
	public EntityStructureProvider getEntityStructureProvider() {
		if(entityStructureProvider==null)
			entityStructureProvider = new EntityStructureProvider(this.getEntityTypeProvider(), this.getViewTypeProvider());
		entityStructureProvider.setDao(dao);
		return entityStructureProvider;
	}
	public EntityTypeProvider getEntityTypeProvider() {
		if(entityTypeProvider==null)
			entityTypeProvider = new EntityTypeProvider(this.getEntityCategoryProvider());
		entityTypeProvider.setDao(dao);
		return entityTypeProvider;
	}
	public ListNameProvider getListNameProvider() {
		if(listNameProvider==null)
			listNameProvider = new ListNameProvider();
		listNameProvider.setDao(dao);
		return listNameProvider;
	}
	public ListValueProvider getListValueProvider() {
		if(listValueProvider==null)
			listValueProvider = new ListValueProvider();
		listValueProvider.setDao(dao);
		return listValueProvider;
	}
	public KeyTypeProvider getKeyTypeProvider() {
		if(keyTypeProvider==null)
			keyTypeProvider = new KeyTypeProvider();
		keyTypeProvider.setDao(dao);
		return keyTypeProvider;
	}
	public EnumNameProvider getEnumNameProvider() {
		if(enumNameProvider==null)
			enumNameProvider = new EnumNameProvider();
		enumNameProvider.setDao(dao);
		return enumNameProvider;
	}
	public EnumValueProvider getEnumValueProvider() {
		if(enumValueProvider==null)
			enumValueProvider = new EnumValueProvider(this.getEnumNameProvider());
		enumValueProvider.setDao(dao);
		return enumValueProvider;
	}
	public SystemPropertyProvider getSystemPropertyProvider() {
		if(systemPropertyProvider == null)
			systemPropertyProvider = new SystemPropertyProvider(getEnumNameProvider(), getKeyTypeProvider(), getListNameProvider());
		systemPropertyProvider.setDao(dao);
		return systemPropertyProvider;
	}
	public KeyDefinitionProvider getKeyDefinitionProvider() {
		if(keyDefinitionProvider==null)
			keyDefinitionProvider = new KeyDefinitionProvider(
			this.getEnumNameProvider(), this.getKeyTypeProvider(), this.getListNameProvider());
		keyDefinitionProvider.setDao(dao);
		return keyDefinitionProvider;
	}
	public KeyValueProvider getKeyValueProvider() {
		if(keyValueProvider==null)
			keyValueProvider = new KeyValueProvider(this.getKeyDefinitionProvider());
		keyValueProvider.setDao(dao);
		return keyValueProvider;
	}
	
}
